import request from "@/utils/request.js";

const url = '/cloud-sys-service/sys-menu'

/**
 * 获取路由列表
 */
export function listRoutes() {
	return request({
		url: url + "/listRoutes",
		method: "get",
	});
}

/**
 * 获取菜单分页列表
 */
export function listMenus(data) {
	return request({
		url: url + "/listMenus",
		method: "post",
		data
	});
}

/**
 * 新增或修改菜单
 */
export function saveOrUpdateMenu(data) {
	return request({
		url: url + "/saveOrUpdateMenu",
		method: "post",
		data
	});
}

/**
 * 删除菜单
 */
export function removeMenu(id) {
	return request({
		url: url + `/removeMenu/${id}`,
		method: "get",
	});
}

/**
 * 获取菜单下拉列表
 */
export function listMenuOptions(params = {flag: true}) {
	return request({
		url: url + "/listMenuOptions",
		method: "get",
		params
	});
}

// 列表相关列信息
export const columnInfo = [
	{
		"title":"菜单名称",
		"field":"name",
		"fixed":"left",
		"align":"left",
		"headerAlign": "center",
		"treeNode":true,
		"proxyColumn":true,
		"minWidth":"200"
	},
	{
		"title":"类型",
		"field":"type",
		"fixed":"left",
		"align":"center",
		"proxyColumn":true,
		"width":"80"
	},
	{
		"title":"路由路径",
		"field":"path",
		"align":"center",
		"width":"150"
	},
	{
		"title":"组件路径",
		"field":"component",
		"align":"center",
		"width":"250"
	},
	{
		"title":"权限标识",
		"field":"perm",
		"align":"center",
		"width":"200"
	},
	{
		"title":"状态",
		"field":"visible",
		"align":"center",
		"proxyColumn":true,
		"width":"80"
	},
	{
		"title":"操作",
		"operate":"true",
		"minWidth":"220px",
		"options":[
			{
				"text":true,
				"btnName":"新增",
				"type":"primary",
				"icon":"Edit",
				"method":"showAddDialog"
			},
			{
				"text":true,
				"btnName":"编辑",
				"type":"primary",
				"icon":"Edit",
				"method":"showFormDialog"
			},
			{
				"text":true,
				"btnName":"删除",
				"type":"primary",
				"icon":"Delete",
				"method":"showRemoveDialog",
				"color":"#ff4949"
			}
		]
	}
]